<?php
class BooksController extends Controller
{
	
	
	public function view($id)
	{
		$book = $this->Book->getById($id);
		//print_r($book);
	}

	public function add()
	{
		if(isset($this->data))
		{
			$newBook = new Book();
			$newBook->clonePropertiesFromArray($this->data);
			$this->Book->add($newBook);
			$this->redirect('books', 'index');
		}
	}
	
	public function index()
	{
		$books = $this->Book->getAll();
		$this->set('books', $books);
		$this->set('title', 'This is the index of the books');
		$this->set('body', 'This is the list of the books');
	}
}